﻿package app.demo.MyTouchApp{
 
    import flash.events.TUIO;// allows to connect to touchlib/tbeta
    import flash.events.TouchEvent;// allows to use TouchEvent Event Listeners
	import flash.events.*;
	import flash.display.*;
    import flash.net.*;
 
    public class MagnifyingGlass extends Sprite {
		
		private var loader:Loader = new Loader();
 		private var imageHolder:MovieClip = new MovieClip();
		public var shrinkFactor:Number=1/3;
		public var magFactor:Number=1/shrinkFactor;
		public var image:Bitmap;


		public var ZoomHolder:MovieClip = new MovieClip();

		public function MagnifyingGlass():void {
 
            //--------connect to TUIO-----------------
            TUIO.init(this,'localhost',3000,'',true);
            trace("MagnifyingGlass() Initialized");
			
			addChild(imageHolder);
			loader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
			loader.load(new URLRequest("image/hiRez-CLE.jpg"));			

			addEventListener(TouchEvent.MOUSE_DOWN, touchDown);                    //run touchDown, when touching environment
			addEventListener(TouchEvent.MOUSE_UP, touchUp);                        //run touchUp, when un-touching environment
			addEventListener(TouchEvent.MOUSE_MOVE, moveUpdate);                   //run moveUpdate, when any touching point is moved
			
			addEventListener(Event.ENTER_FRAME, extraClear);
        }
		
		private function imageLoaded(event:Event):void
		{
			image = new Bitmap(event.target.content.bitmapData);
			imageHolder.addChild(image);
			imageHolder.scaleX=shrinkFactor;
			imageHolder.scaleY=shrinkFactor;
			imageHolder.addEventListener(TouchEvent.MOUSE_DOWN,touchDown);
			
			addChild(ZoomHolder);
		}

		public function updateCall():void{  
        }
		
		public function extraClear(e:Event):void{
        }
		public function touchDown(e:TouchEvent):void{
			var intX = e.stageX;
			var intY = e.stageY;
			var newBox:ZoomBox = new ZoomBox(intX, intY);
			ZoomHolder.addChild(newBox);
			newBox.addEventListener(TouchEvent.MOUSE_MOVE,positionZoom);
        }
		public function positionZoom(e:TouchEvent):void{
		}		
		public function touchUp(e:TouchEvent):void{
		}
		public function moveUpdate(e:TouchEvent):void{
		}
    }
}

import flash.display.*;
import flash.geom.Point;
import flash.net.*;
import flash.events.Event;
import app.core.action.RotatableScalable;

class ZoomBox extends RotatableScalable {
	
	public var thisname:String;
	private var loader:Loader = new Loader();
	private var imageHolder:MovieClip = new MovieClip();
	public var image:Bitmap;
	
	public function ZoomBox(intX, intY):void{
		
		this.x = intX;
		this.y = intY;
		addChild(imageHolder);
		loader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
		loader.load(new URLRequest("image/hiRez-CLE.jpg"));			

	}
	private function imageLoaded(event:Event):void
	{
		image = new Bitmap(event.target.content.bitmapData);
		imageHolder.addChild(image);
	}
}

